import pulpcore.Stage;
import pulpcore.sprite.ImageSprite;
import pulpcore.image.CoreImage;
public class mario extends ImageSprite{
	private CoreImage standingRight;
	private CoreImage standingLeft;
	//private CoreImage running;
	private boolean thrust = false;
	private double xVelocity = 0;
	private double yVelocity = 0;
	private final double ACCELERATION = 0.1;
	private final double MAXIMUM_ACCELERATION = 5;
	private final double FRICTION = 0.995;
	private double time=-11;
	public mario(int x, int y){
		super(CoreImage.load("FINISHED8bit-mario Right Backup.PNG"), x, y);
		standingRight = (CoreImage.load("FINISHED8bit-mario Right Backup.PNG"));
		standingLeft = (CoreImage.load("FINISHED8bit-mario Left Backup.PNG"));
	}
	public void update(int elapsedTime)
	{
		super.update(elapsedTime);
		
		
		movePlayer();
		//wrapAroundScreen();
	}
	private void movePlayer()
	{
	    if(jump()){
	    	jump();
	    }	
		x.set(x.get() + xVelocity);
	    y.set(y.get() + yVelocity);
	}
		
	public boolean isThrust()
	{
		return thrust;
	}

	public void setThrust(boolean thrust)
	{
		this.thrust = thrust;
		
		if(thrust)
		{
			setImage(standingRight);
		}
		else
		{
			xVelocity=0;
		}
	}
	public void runLeft()
	{
		setImage(standingLeft);
		xVelocity = -8;	

	}
	
	public void runRight()
	{
		setImage(standingRight);
		xVelocity = 8;
	}

	public boolean jump()
	{		
		if(time >-11 && time <8){
			time++;
			yVelocity=(Math.pow(time*.725,(3)));
			return true;
		}
		else
			yVelocity=0;
			time=-11;
			return false;
	}
	public void starter(){
		time++;
	}
	public double getX(){
		return x.get();
	}
}
